import QtQuick 2.0
import QtGraphicalEffects 1.12
Rectangle {
    id: rect
    property alias btnNameColor: btnName.color
    property alias btnNameText: btnName.text
    property var pressColor
    property var normalColor: "#44576E"
    property bool isChecked: false
    layer.enabled: true
    layer.effect: DropShadow {
        horizontalOffset: 5
        verticalOffset: 5
        radius: 10
        color: "#F0000000"  // 半透明黑色
    }
    signal checked()

    width: 224
    height: 108
    radius: 20
    border.color: color
    border.width: 1
    color: isChecked ? pressColor : normalColor
    opacity: 0.5

    Text {
        id: btnName
        anchors.centerIn: parent
        font{
            family: "Microsoft YaHei"
            pixelSize: 30
        }
    }

    MouseArea{
        anchors.fill: parent
        onPressed: {
            rect.color = pressColor
            isChecked = true
        }
        onReleased: {
            checked()
        }
    }
    onIsCheckedChanged: {
        if(isChecked){
            rect.color = pressColor
        }else{
            rect.color = normalColor
        }
    }
}
